package com.ncmmall.querychannel;

import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * @author linxs
 */
@Resource(name="jpaQueryRepository")
public final class JpaQueryRepository extends AbstractJpaQueryRepository {

	@PersistenceContext(unitName="em")
	private EntityManager entityManager;
	
	private QueryRepositoryFilter queryRepositoryFilter;
	
	public void setQueryRepositoryFilter(QueryRepositoryFilter queryRepositoryFilter) {
		this.queryRepositoryFilter = queryRepositoryFilter;
	}
	
	public QueryRepositoryFilter getQueryRepositoryFilter() {
		return this.queryRepositoryFilter;
	}
	
	@Override
	protected EntityManager getEntityManager() {
		return entityManager;
	}

	@Override
	protected String filter(String query, QueryPageRequest pageRequest) {
		return queryRepositoryFilter.invoke(query, pageRequest);
	}
}
